home *** CD-ROM | disk | FTP | other *** search
/ Exame Informatica 139 / Exame Informatica 139.iso / Revista / Flash / Uniform Server / diskw / home / admin / www / phpMyAdmin / left.php < prev    next >
Encoding:
PHP Script  |  2005-10-20  |  43.7 KB  |  951 lines

  1. <?php
  2. /* $Id: left.php,v 2.45.2.1 2005/10/21 01:24:00 lem9 Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. /**
  7.  * Gets the variables sent to this script, retains the db name that may have
  8.  * been defined as startup option and include a core library
  9.  */
  10. require_once('./libraries/grab_globals.lib.php');
  11. if (isset($lightm_db) && !empty($lightm_db)) {
  12. // no longer urlencoded because of html entities in the db name
  13. //    $db = urldecode($lightm_db);
  14.     $db = $lightm_db;
  15. }
  16.  
  17. if (!empty($db)) {
  18.     $db_start = $db;
  19. }
  20.  
  21.  
  22. /**
  23.  * Gets a core script and starts output buffering work
  24.  */
  25. require_once('./libraries/common.lib.php');
  26. require_once('./libraries/ob.lib.php');
  27. if ($cfg['OBGzip']) {
  28.     $ob_mode = PMA_outBufferModeGet();
  29.     if ($ob_mode) {
  30.         PMA_outBufferPre($ob_mode);
  31.     }
  32. }
  33.  
  34. // This check had been put here to avoid revealing the full path
  35. // of the phpMyAdmin directory in case this script is called
  36. // directly. But some users report a "Missing hash" message and
  37. // I cannot reproduce it, so let's define $hash to a dummy value
  38. // and hope some other clue will surface, to sort this bug.
  39. //PMA_checkParameters(array('hash'));
  40. if (!isset($hash)) {
  41.     $hash='';
  42. } else {
  43.     $hash = PMA_sanitize($hash);
  44. }
  45.  
  46. require_once('./libraries/bookmark.lib.php');
  47. require_once('./libraries/relation.lib.php');
  48. $cfgRelation = PMA_getRelationsParam();
  49.  
  50. function PMA_multimerge(&$stack, &$table) {
  51. global $list_item, $table_item;
  52.  
  53.     $key = array_shift($table);
  54.  
  55.     if (count($table) > 0) {
  56.         if (!isset($stack[$key])) {
  57.             $stack[$key] = '';
  58.         }
  59.         PMA_multimerge($stack[$key], $table);
  60.     } else {
  61.         $stack['pma_name'][]      = $table_item;
  62.         $stack['pma_list_item'][] = $list_item;
  63.     }
  64. }
  65.  
  66. /* This will take a 1-dimensional array, and shift as many elemnts off
  67.  * the end, until the allowed maximum level is reached */
  68. function PMA_reduceNest(&$_table) {
  69.     if ($GLOBALS['cfg']['LeftFrameTableLevel'] > 0) {
  70.         $elements = count($_table);
  71.         for ($ti = $elements; $ti > $GLOBALS['cfg']['LeftFrameTableLevel']; $ti--) {
  72.             unset($_table[$ti]);
  73.         }
  74.     }
  75. }
  76.  
  77. function PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val, $childout = true) {
  78.     $name = $key;
  79.     //$id = preg_replace('@[^a-z0-9]*@i', '', $baseid . $keyhistory . $key) . $indent;
  80.     $id = base64_encode($baseid . $keyhistory . $key) . $indent;
  81.  
  82.     $groupkey = $keyhistory . ($key != $keyhistory ? $GLOBALS['cfg']['LeftFrameTableSeparator'] . $key : '');
  83.  
  84.     $on_mouse = (($GLOBALS['cfg']['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $id . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
  85.  
  86.     $countarray = $val;
  87.     if (count($countarray) == 2 && isset($countarray['pma_name']) && isset($countarray['pma_list_item'])) {
  88.         $counter = count($countarray['pma_name']);
  89.     } else {
  90.         unset($countarray['pma_name']);
  91.         if (count($countarray) > 1) {
  92.             unset($countarray['pma_list_item']);
  93.         }
  94.         $counter = count($countarray);
  95.     }
  96.  
  97.     echo "\n";
  98.     echo str_repeat(' ', $indent * 5) . '<div id="el' . $id . 'Parent" class="parent"' . $on_mouse . '>' . "\n";
  99.     echo str_repeat(' ', $indent * 6) . '<div class="nowrap"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" border="0" width="' . (($indent - 1) * $indent_level) . '" height="9" alt="" /><a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '&tbl_group=' . htmlspecialchars($groupkey) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', true); return false} else {return true}">';
  100.     echo '<img name="imEx" id="el' . $id . 'Img" src="' . $GLOBALS['pmaThemeImage'] . 'b_plus.png" border="0" width="9" height="9" alt="+" /></a>' . "\n";
  101.     echo str_repeat(' ', $indent * 6) . '<a class="item" href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['common_url_query'] . '&tbl_group=' . htmlspecialchars($groupkey) . '" title="' . htmlspecialchars($name) . '" onclick="if (capable) {expandBase(\'el' . $id . '\', false)}"><span class="heada">' . htmlspecialchars($name) . '<bdo dir="' . $GLOBALS['text_dir'] . '">  </bdo></span><span class="headaCnt">(' . $counter . ')</span></a></div>' . "\n";
  102.     echo str_repeat(' ', $indent * 5) . '</div><!-- class="PMA_nestedSetHeaderParent" -->' . "\n";
  103.     echo "\n";
  104.  
  105.     if ($childout) {
  106.         echo str_repeat(' ', $indent * 5) . '<div id="el' . $id . 'Child" class="child nowrap" ' . $on_mouse . '>' . "\n";
  107.     }
  108. }
  109.  
  110. function PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut, $firstGroup = false, $firstGroupClose = true) {
  111.     if ($firstGroup) {
  112.         PMA_nestedSetHeaderParent($baseid, $firstGroup, $keyhistory, $indent, $indent_level, $tablestack);
  113.         $indent++;
  114.     }
  115.  
  116.     foreach ($tablestack AS $key => $val) {
  117.         if ($key != 'pma_name' && $key != 'pma_list_item') {
  118.             if ($headerOut) {
  119.                 PMA_nestedSetHeaderParent($baseid, $key, $keyhistory, $indent, $indent_level, $val);
  120.             }
  121.  
  122.             if (isset($val['pma_name']) && isset($val['pma_list_item']) && count($val) == 2) {
  123.                 PMA_nestedSet($baseid, $val, $key, $keyhistory . ($keyhistory != '' ? $GLOBALS['cfg']['LeftFrameTableSeparator'] : '') . $key, false, ($indent + 1));
  124.             } else {
  125.                 PMA_nestedSet($baseid, $val, $key, $keyhistory . ($keyhistory != '' ? $GLOBALS['cfg']['LeftFrameTableSeparator'] : '') . $key, true, ($indent + 1));
  126.             }
  127.  
  128.             if ($headerOut) {
  129.                 echo str_repeat(' ', $indent * 5) . '</div><!-- class="PMA_nestedSetHeader" -->' . "\n";
  130.             }
  131.         }
  132.     }
  133.  
  134.     if ($firstGroup && $firstGroupClose) {
  135.         echo str_repeat(' ', $indent * 4) . '</div><!-- class="PMA_nestedSetHeader2" -->' . "\n";
  136.     } elseif ($firstGroup) {
  137.         echo str_repeat(' ', $indent * 4) . '<!-- spacer="div omitted" class="PMA_nestedSetHeader2" -->' . "\n";
  138.     }
  139. }
  140.  
  141. function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory = '', $headerOut = false, $indent = 1) {
  142.  
  143.     if ($keyhistory == '' && $key != '__protected__') {
  144.         $keyhistory = $key;
  145.     }
  146.  
  147.     $indent_level = 9;
  148.  
  149.     if (isset($tablestack)
  150.         && isset($tablestack['pma_name'])
  151.         && isset($tablestack['pma_list_item'])) {
  152.  
  153.         if (count($tablestack) > 1 && !empty($key) && isset($tablestack['pma_name']) && isset($tablestack['pma_list_item']) && $indent == 1) {
  154.             PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, ($indent+1), $indent_level, $headerOut, $key, false);
  155.             $divClose = true;
  156.             $extra_indent = 1;
  157.         } else {
  158.             PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, $indent, $indent_level, $headerOut);
  159.             $divClose = false;
  160.             $extra_indent = 0;
  161.         }
  162.  
  163.         $on_mouse = (($GLOBALS['cfg']['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $keyhistory . $key . '\', \'' . $GLOBALS['cfg']['LeftBgColor'] . '\')}"');
  164.  
  165.         $loops = 0;
  166.         foreach ($tablestack['pma_name'] AS $tkey => $tval) {
  167.  
  168.             echo str_repeat(' ', $indent * 5) . '<img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' .'" border="0" width="' . (($indent+$extra_indent) * $indent_level) . '" height="9" alt="" />';
  169.             $items = explode("\n", $tablestack['pma_list_item'][$tkey]);
  170.             foreach ($items AS $ikey => $ival) {
  171.                 echo "\n";
  172.                 echo str_repeat(' ', ($indent * 5)) . $ival;
  173.             }
  174.             echo "\n";
  175.  
  176.             $loops++;
  177.         }
  178.  
  179.         if ($divClose) {
  180.             echo str_repeat(' ', $indent * 5) . '</div><!-- space="putting omitted div" class="PMA_nestedSet2" -->';
  181.         }
  182.  
  183.     } elseif (is_array($tablestack)) {
  184.         PMA_nestedSetHeader($baseid, $tablestack, $keyhistory, (($key == '__protected__' && $indent == 1 )? ($indent-1) : ($indent + 1)), $indent_level, $headerOut,  (($key == '__protected__' && $indent == 1) || ($indent > 1) ? false : $key));
  185.     }
  186.  
  187.     return true;
  188. }
  189. /**
  190.  * Get the list and number of available databases.
  191.  * Skipped if no server selected: in this case no database should be displayed
  192.  * before the user choose among available ones at the welcome screen.
  193.  */
  194. if ($server > 0) {
  195.     PMA_availableDatabases(); // this function is defined in "common.lib.php"
  196. } else {
  197.     $num_dbs = 0;
  198. }
  199.  
  200.  
  201. // garvin: For re-usability, moved http-headers
  202. // to a seperate file. It can now be included by header.inc.php,
  203. // queryframe.php, querywindow.php.
  204.  
  205. require_once('./libraries/header_http.inc.php');
  206.  
  207. /**
  208.  * Displays the frame
  209.  */
  210. // Gets the font sizes to use
  211. PMA_setFontSizes();
  212. echo "<?xml version=\"1.0\" encoding=\"" . $GLOBALS['charset'] . "\"?".">"; // remove vertical scroll bar bug in ie
  213. ?>
  214. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  215.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  216. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $available_languages[$lang][2]; ?>" lang="<?php echo $available_languages[$lang][2]; ?>" dir="<?php echo $text_dir; ?>">
  217.  
  218. <head>
  219.     <title>phpMyAdmin</title>
  220.     <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
  221.     <base<?php if (!empty($cfg['PmaAbsoluteUri'])) echo ' href="' . $cfg['PmaAbsoluteUri'] . '"'; ?> target="phpmain<?php echo $hash; ?>" />
  222.  
  223.     <script type="text/javascript" language="javascript">
  224.     <!--
  225.     function goTo(targeturl, targetframe) {
  226.         if (!targetframe) {
  227.             targetframe = self;
  228.         }
  229.  
  230.         if (targetframe) {
  231. <?php if (PMA_USR_BROWSER_AGENT != 'SAFARI') { ?>
  232.             targetframe.location.replace(targeturl);
  233. <?php } else { ?>
  234.             targetframe.location.href = targeturl;
  235. <?php } ?>
  236.         }
  237.  
  238.         return true;
  239.     }
  240.  
  241. <?php
  242. if (isset($lightm_db) && !empty($lightm_db)) {
  243. ?>
  244.     goTo('./<?php echo $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db, '', '&');?>', window.parent.frames['phpmain<?php echo $hash; ?>']);
  245. <?php
  246. } elseif (isset($lightm_db)) {
  247. ?>
  248.     goTo('./main.php?<?php echo PMA_generate_common_url('', '', '&');?>', window.parent.frames['phpmain<?php echo $hash; ?>']);
  249. <?php
  250. }
  251. ?>
  252.     //-->
  253.     </script>
  254.  
  255. <?php
  256. // Expandable/collapsible databases list is only used if there is more than one
  257. // database to display
  258. if (($num_dbs > 1 || !empty($cfg['LeftFrameTableSeparator'])) && !$cfg['LeftFrameLight']) {
  259.     echo "\n";
  260.     ?>
  261.     <!-- Collapsible tables list scripts -->
  262.     <script type="text/javascript" language="javascript">
  263.     <!--
  264.     var imgUrlPlus  = "<?php echo $GLOBALS['pmaThemeImage'] . 'b_plus.png'; ?>";
  265.     var imgUrlMinus = "<?php echo $GLOBALS['pmaThemeImage'] . 'b_minus.png'; ?>";
  266.     var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
  267.                       && typeof(document.createElement) != 'undefined')
  268.                    ? 1 : 0;
  269.     var isIE4      = (typeof(document.all) != 'undefined'
  270.                       && parseInt(navigator.appVersion) >= 4)
  271.                    ? 1 : 0;
  272.     var isNS4      = (typeof(document.layers) != 'undefined')
  273.                    ? 1 : 0;
  274.     var capable    = (isDOM || isIE4 || isNS4)
  275.                    ? 1 : 0;
  276.     // Uggly fix for Opera and Konqueror 2.2 that are half DOM compliant
  277.     if (capable) {
  278.         if (typeof(window.opera) != 'undefined') {
  279.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  280.             if ((browserName.indexOf('konqueror 7') == 0)) {
  281.                 capable = 0;
  282.             }
  283.         }
  284.         else if (typeof(navigator.userAgent) != 'undefined') {
  285.             var browserName = ' ' + navigator.userAgent.toLowerCase();
  286.             if ((browserName.indexOf('konqueror') > 0) && (browserName.indexOf('konqueror/3') == 0)) {
  287.                 capable = 0;
  288.             }
  289.         } // end if... else if...
  290.     } // end if
  291.  
  292.     var isServer    = <?php echo ($server > 0) ? 'true' : 'false'; ?>;
  293.  
  294.     document.writeln('<link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&js_frame=left&js_capable=' + capable + '&js_isDOM=' + isDOM + '&js_isIE4=' + isIE4 + '" />');
  295.     //-->
  296.     </script>
  297. <noscript>
  298.         <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?<?php echo PMA_generate_common_url(); ?>&js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  299. </noscript>
  300.  
  301.     <script src="libraries/left.js" type="text/javascript" language="javascript1.2"></script>
  302.     <?php
  303. } // end if ($num_dbs > 1)
  304.  
  305. else if ($num_dbs == 1) {
  306.     echo "\n";
  307.     ?>
  308.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&js_capable=0&js_isDOM=0&js_isIE4=0" />
  309.     <?php
  310. } // end if ($num_dbs == 1)
  311.  
  312. else {
  313.     echo "\n";
  314.     ?>
  315.     <link rel="stylesheet" type="text/css" href="./css/phpmyadmin.css.php?js_frame=left&num_dbs=0" />
  316.     <?php
  317. } // end if ($num_dbs < 1)
  318.  
  319. echo "\n";
  320. ?>
  321. </head>
  322.  
  323. <body bgcolor="<?php echo $cfg['LeftBgColor']; ?>" id="body_leftFrame">
  324.  
  325. <?php
  326. if ($cfg['LeftDisplayLogo'] && !$cfg['QueryFrame']) {
  327. ?>
  328. <!-- phpMyAdmin logo -->
  329. <?php
  330.     if (@file_exists($pmaThemeImage . 'logo_left.png')) {
  331. ?>
  332.     <div align="center">
  333.         <a href="http://www.phpmyadmin.net" target="_blank"><img src="<?php echo '' . $pmaThemeImage . 'logo_left.png'; ?>" alt="phpMyAdmin" vspace="3" border="0" /></a>
  334.     </div>
  335. <?php
  336.     } else {
  337.         echo '<div align="center"><a href="http://www.phpmyadmin.net" target="_blank">';
  338.         echo '<img src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo2.png' . '" alt="phpMyAdmin" border="0" />';
  339.         echo '</a></div>' . "\n";
  340.     }
  341.     echo '<hr />';
  342. } // end of display logo
  343. echo "\n";
  344.  
  345. if (!$cfg['QueryFrame']) {
  346.     echo "\n";
  347. ?>
  348. <!-- Link to the welcome page -->
  349.     <div id="el1Parent" class="parent nowrap" align="center">
  350.     <?php
  351.     if ($cfg['MainPageIconic']) {
  352.         $str_spacer_links='';
  353.     } else{
  354.         $str_spacer_links=' - ';
  355.     }
  356.     echo '<a class="item" href="main.php?' . PMA_generate_common_url() . '" target="phpmain' . $hash . '">'
  357.        . ($cfg['MainPageIconic']
  358.             ? '<img src="' . $pmaThemeImage . 'b_home.png" width="16" height="16" border="0" hspace="2" alt="' . $strHome . '" title="' . $strHome . '"'
  359.                 .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
  360.             : '<b>' . $strHome . '</b>')
  361.        . '</a>';
  362.     // if we have chosen server show logout for advanced authentication
  363.     if ($server != 0 && $cfg['Server']['auth_type'] != 'config') {
  364.         echo $str_spacer_links;
  365.         echo '<a class="item" href="index.php?' . PMA_generate_common_url() . '&old_usr=' . urlencode($PHP_AUTH_USER) . '" target="_parent">'
  366.            . ($cfg['MainPageIconic']
  367.                 ? '<img src="' . $pmaThemeImage . 's_loggoff.png" width="16" height="16" border="0" hspace="2" alt="' . $strLogout . '" title="' . $strLogout . '"'
  368.                     .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
  369.                 : '<b>' . $strLogout . '</b>')
  370.            . '</a>';
  371.     } // end if
  372.     if ($cfg['MainPageIconic']) {
  373.         echo '<img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="2" height="1" border="0" />'
  374.            . '<a href="Documentation.html" target="documentation" class="item">'
  375.            . '<img src="' . $pmaThemeImage . 'b_docs.png" border="0" hspace="1" width="16" height="16" alt="' . $strPmaDocumentation . '" title="' . $strPmaDocumentation . '"'
  376.            .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
  377.            . '</a>';
  378.        echo ''
  379.            . '<a href="' . $cfg['MySQLManualBase'] . '" target="documentation" class="item">'
  380.            . '<img src="' . $pmaThemeImage . 'b_sqlhelp.png" border="0" hspace="1" width="16" height="16" alt="MySQL - ' . $strDocu . '" title="MySQL - ' . $strDocu . '"'
  381.            .' onmouseover="this.style.backgroundColor=\'#ffffff\';" onmouseout="this.style.backgroundColor=\'\';" align="middle" />'
  382.            . '</a>';
  383.     }
  384. ?>
  385.     </div>
  386.     <hr />
  387. <?php
  388.     if ($cfg['LeftDisplayServers']) {
  389.         $show_server_left = TRUE;
  390.         include('./libraries/select_server.lib.php');
  391.     }
  392. } // end !$cfg['QueryFrame']
  393.  
  394. ?>
  395. <!-- Databases and tables list -->
  396. <div id="left_tableList">
  397. <?php
  398. // Don't display expansible/collapsible database info if:
  399. // 1. $server == 0 (no server selected)
  400. //    This is the case when there are multiple servers and
  401. //    '$cfg['ServerDefault'] = 0' is set. In that case, we want the welcome
  402. //    screen to appear with no database info displayed.
  403. // 2. there is only one database available (ie either only one database exists
  404. //    or $cfg['Servers']['only_db'] is defined and is not an array)
  405. //    In this case, the database should not be collapsible/expandable
  406. if ($num_dbs > 1) {
  407.  
  408.     // Light mode -> beginning of the select combo for databases
  409.     // Note: When javascript is active, the frameset will be changed from
  410.     // within left.php. With no JS (<noscript>) the whole frameset will
  411.     // be rebuilt with the new target frame.
  412.     if ($cfg['LeftFrameLight']) {
  413.         if (!$cfg['QueryFrame']) {
  414.         ?>
  415.     <script type="text/javascript" language="javascript">
  416.     <!--
  417.         document.writeln('<form method="post" action="left.php" name="left" target="nav" style="margin: 0px; padding: 0px;">');
  418.     //-->
  419.     </script>
  420.     <noscript>
  421.         <form method="post" action="index.php" name="left" target="_parent" style="margin: 0px; padding: 0px;">
  422.     </noscript>
  423.     <?php
  424.             echo PMA_generate_common_hidden_inputs();
  425.             echo '        <input type="hidden" name="hash" value="' . $hash . '" />' . "\n";
  426.             echo '        <span class="heada"><b>' . $strDatabase . ':</b></span><br />';
  427.             echo '        <select name="lightm_db" onchange="this.form.submit()">' . "\n";
  428.             echo '            <option value="">(' . $strDatabases . ') ...</option>' . "\n";
  429.         } // end !$cfg['QueryFrame']
  430.  
  431.         $table_list = '';
  432.         $table_list_header = '';
  433.         $db_name    = '';
  434.     } // end FrameLight
  435.  
  436.     $selected_db = 0;
  437.  
  438.     // natural order for db list; but do not sort if user asked
  439.     // for a specific order with the 'only_db' mechanism
  440.  
  441.     if (!is_array($cfg['Server']['only_db']) && $cfg['NaturalOrder'] && $num_dbs > 0) {
  442.         $dblist_temp = $dblist;
  443.         natsort($dblist_temp);
  444.         $i = 0;
  445.         foreach ($dblist_temp as $each) {
  446.             $dblist[$i] = $each;
  447.             $i++;
  448.         }
  449.     }
  450.  
  451.     // Gets the tables list per database
  452.     for ($i = 0; $i < $num_dbs; $i++) {
  453.         $db = $dblist[$i];
  454.         $j  = $i + 2;
  455.         if (!empty($db_start) && $db == $db_start) {
  456.             $selected_db = $j;
  457.         }
  458.         /**
  459.          * The query below will return a result set with a single field under
  460.          * MySQL versions before 5.0 and one with two fields under MySQL 5.0
  461.          * and above. The MySQL 5 result set also includes the table type
  462.          * ('BASE TABLE', 'VIEW' or 'TEMPORARY').
  463.          * MySQL 4 does neither know about views nor differ between permanent
  464.          * and temporary tables, so the table type is irrelevant here.
  465.          */
  466.         $tables              = PMA_DBI_try_query('SHOW ' . (PMA_MYSQL_INT_VERSION >= 50000 ? 'FULL ' : '') . 'TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
  467.         $num_tables          = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
  468.         $common_url_query    = PMA_generate_common_url($db);
  469.         if ($num_tables) {
  470.             $num_tables_disp = $num_tables;
  471.         } else {
  472.             $num_tables_disp = '-';
  473.         }
  474.  
  475.         // Get additional information about tables for tooltip
  476.         if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  477.             && $num_tables
  478.             && (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
  479.             $tooltip = array();
  480.             $tooltip_name = array();
  481.             $result  = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
  482.             while ($tmp = PMA_DBI_fetch_assoc($result)) {
  483.                 $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  484.                 $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
  485.  
  486.                 $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  487.                                        . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  488.             } // end while
  489.         } // end if
  490.  
  491.         // garvin: Get comments from PMA comments table
  492.         $db_tooltip = '';
  493.         if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  494.             $tmp_db_tooltip = PMA_getComments($db);
  495.             if (is_array($tmp_db_tooltip)) {
  496.                 $db_tooltip = implode(' ', $tmp_db_tooltip);
  497.             }
  498.         }
  499.  
  500.         // No light mode -> displays the expandible/collapsible db list
  501.         if ($cfg['LeftFrameLight'] == FALSE) {
  502.  
  503.             // Displays the database name
  504.             $on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el' . $j . '\', \'' . $cfg['LeftBgColor'] . '\')}"');
  505.  
  506.             echo "\n";
  507.             echo '    <div id="el' . $j . 'Parent" class="parent nowrap"' . $on_mouse . '>';
  508.  
  509.             if (!empty($num_tables)) {
  510.                 echo "\n";
  511.             ?>
  512.             <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', true); return false} else {return true}">
  513.             <img name="imEx" id="el<?php echo $j; ?>Img" src="<?php echo $pmaThemeImage; ?>b_plus.png" border="0" width="9" height="9" alt="+" /></a>
  514.             <?php
  515.             } else {
  516.                 echo "\n";
  517.             ?>
  518.             <img name="imEx" src="<?php echo $pmaThemeImage; ?>b_minus.png" border="0" width="9" height="9" alt="-" />
  519.             <?php
  520.             }
  521.             echo "\n";
  522.             ?>
  523.             <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el<?php echo $j; ?>', false)}">
  524.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a>
  525.         </div>
  526.  
  527.         <div id="el<?php echo $j;?>Child" class="child nowrap" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  528.         <?php
  529.             // Displays the list of tables from the current database
  530.             $tablestack  = array();
  531.             $table_array = array();
  532.             $table_types = array();
  533.             while (@list($table, $type) = PMA_DBI_fetch_row($tables)) {
  534.                 $table_item = (!empty($tooltip_name) && isset($tooltip_name[$table]) && !empty($tooltip_name[$table]) && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  535.                             ? htmlspecialchars($tooltip_name[$table])
  536.                             : htmlspecialchars($table));
  537.                 $table_array[$table] = $table_item;
  538.                 $table_types[$table] = empty($type) ? 'BASE TABLE' : $type;
  539.             }
  540.  
  541.             if ($cfg['NaturalOrder']) {
  542.                 natsort($table_array);
  543.             }
  544.  
  545.             $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
  546.             foreach ($table_array as $table => $table_sortkey) {
  547.                 $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  548.                            ? htmlspecialchars($tooltip_name[$table])
  549.                            : '';
  550.                 $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  551.                            ? htmlspecialchars($tooltip[$table])
  552.                            : '';
  553.                 $table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  554.                             ? $alias
  555.                             : htmlspecialchars($table));
  556.                 $tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
  557.                            ? $alias
  558.                            : htmlspecialchars($table));
  559.  
  560.                 $book_sql_query = (isset($book_sql_cache[$table]) ? $book_sql_cache[$table] : FALSE);
  561.  
  562.                 $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
  563.                 $list_item .= '<img src="' . $pmaThemeImage . ($table_types[$table] == 'VIEW' ? 's_views' : 'b_sbrowse') . '.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  564.                 $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  565.                 $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  566.                 $list_item .= $table_item . '</a><br />' . "\n";
  567.  
  568.                 // garvin: Check whether to display nested sets
  569.                 if (!empty($cfg['LeftFrameTableSeparator'])) {
  570.                     $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'', $tablename));
  571.                     if (is_array($_table)) {
  572.                         foreach ($_table AS $key => $val) {
  573.                             if ($val == '') {
  574.                                 $_table[$key] = '__protected__';
  575.                             }
  576.                         }
  577.                         PMA_reduceNest($_table);
  578.  
  579.                         if (count($_table) == 1) {
  580.                             array_unshift($_table, '');
  581.                         }
  582.                         PMA_multimerge($tablestack, $_table);
  583.                     } else {
  584.                         $tablestack['']['pma_name'][] = $table_item;
  585.                         $tablestack['']['pma_list_item'][] = $list_item;
  586.                     }
  587.                 } else {
  588.                     $tablestack['']['pma_name'][] = $table_item;
  589.                     $tablestack['']['pma_list_item'][] = $list_item;
  590.                 }
  591.             } // end while (tables list)
  592.  
  593.             PMA_nestedSet($j, $tablestack);
  594.         ?>
  595.         </div>
  596.         <?php
  597.             echo "\n";
  598.         }
  599.  
  600.         // Light mode -> displays the select combo with databases names and the
  601.         // list of tables contained in the current database
  602.         else {
  603.             echo "\n";
  604.  
  605.             // Builds the databases' names list
  606.             if (!empty($db_start) && $db == $db_start) {
  607.                 $table_title = array();
  608.                 $table_array = array();
  609.                 // Gets the list of tables from the current database
  610.                 $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
  611.                 while (@list($table, $type) = PMA_DBI_fetch_row($tables)) {
  612.                     $table_array[$table] = '';
  613.                     $url_title  = (!empty($tooltip) && isset($tooltip[$table]))
  614.                                 ? htmlspecialchars($tooltip[$table])
  615.                                 : '';
  616.                     $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  617.                                ? htmlspecialchars($tooltip_name[$table])
  618.                                : '';
  619.  
  620.                     $book_sql_query = (isset($book_sql_cache[$table]) ? $book_sql_cache[$table] : FALSE);
  621.  
  622.                     // natural order or not, use an array for the table list
  623.  
  624.                     $table_array[$table] .= '    <div class="nowrap"><a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '">' . "\n";
  625.                     $table_array[$table] .= '              <img src="' . $pmaThemeImage . (!empty($type) && $type == 'VIEW' ? 's_views' : 'b_sbrowse') . '.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" title="' . $strBrowse . ': ' . $url_title . '" /></a><bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  626.  
  627.                     if (PMA_USR_BROWSER_AGENT == 'IE') {
  628.                         $table_array[$table] .= '          <span class="tblItem"><a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></span></div>' . "\n";
  629.                     } else {
  630.                         $table_array[$table] .= '          <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></div>' . "\n";
  631.                     }
  632.  
  633.                     $table_title[$table] = htmlspecialchars($table);
  634.  
  635.                 } // end while (tables list)
  636.  
  637.                 if (count($table_title) > 0) {
  638.                     if ($cfg['NaturalOrder'] && $num_tables > 0) {
  639.                         natsort($table_title);
  640.                     }
  641.  
  642.                     foreach ($table_title as $each_key => $each_val) {
  643.                         $table_list .= ' ' . $table_array[$each_key];
  644.                     }
  645.                 } else {
  646.                     $table_list = '    <br /><br />' . "\n"
  647.                                 . '    <div>' . $strNoTablesFound . '</div>' . "\n";
  648.                 }
  649.                 $selected = ' selected="selected"';
  650.  
  651.                 $table_list_header .= '    <a class="item" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabDatabase'] . '?' . $common_url_query . '">' . "\n";
  652.                 $table_list_header .= '        <span class="heada"><b>' . ($db_tooltip != '' && $cfg['ShowTooltipAliasTB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . '</b><bdo dir="' . $text_dir . '">  </bdo></span></a><br />' . "\n\n";
  653.             } else {
  654.                 $selected = '';
  655.             } // end if... else...
  656.             if (!$cfg['QueryFrame']) {
  657.                 if (!empty($num_tables)) {
  658.                     echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>'
  659.                        . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (' . $num_tables . ')</option>' . "\n";
  660.                 } else {
  661.                     echo '            <option value="' . htmlspecialchars($db) . '"' . $selected . '>'
  662.                        . ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)) . ' (-)</option>' . "\n";
  663.                 }
  664.             } // end !$cfg['QueryFrame']
  665.  
  666.         } // end if (light mode)
  667.  
  668.     } // end for $i (db list)
  669.  
  670.     // Light mode -> end of the select combo for databases and table list for
  671.     // the current database
  672.     if ($cfg['LeftFrameLight']) {
  673.         if (!$cfg['QueryFrame']) {
  674.             echo '        </select>' . "\n";
  675.             echo '        <noscript><input type="submit" name="Go" value="' . $strGo . '" /></noscript>' . "\n";
  676.             echo '    </form>' . "\n";
  677.         }
  678.         if (!$table_list) {
  679.             $table_list = '    <div align="center"><b>' . $strSelectADb . '</b></div>' . "\n";
  680.         }
  681.  
  682.         // Displays the current database name and the list of tables it
  683.         // contains
  684.         if (!$cfg['QueryFrame']) {
  685.            echo '<hr />';
  686.         }
  687.         echo $table_list_header;
  688.         echo $table_list;
  689.     }
  690.  
  691.     // No light mode -> initialize some js variables for the
  692.     // expandible/collapsible stuff
  693.     else {
  694.     ?>
  695.  
  696.     <!-- Arrange collapsible/expandable db list at startup -->
  697.     <script type="text/javascript" language="javascript1.2">
  698.     <!--
  699.         if (isNS4) {
  700.             firstEl  = 'el1Parent';
  701.             firstInd = nsGetIndex(firstEl);
  702.             nsShowAll();
  703.             nsArrangeList();
  704.         }
  705.         var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  706.     //-->
  707.     </script>
  708.     <?php
  709.  
  710.     } // end if... else... (light mode)
  711.  
  712. } // end if ($server > 1)
  713.  
  714.  
  715. // Case where only one database has to be displayed
  716. else if ($num_dbs == 1) {
  717.     $db                  = $dblist[0];
  718.     $tables              = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
  719.     $num_tables          = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
  720.     $common_url_query    = PMA_generate_common_url($db);
  721.     if ($num_tables) {
  722.         $num_tables_disp = $num_tables;
  723.     } else {
  724.         $num_tables_disp = '-';
  725.     }
  726.  
  727.     // Get additional infomation about tables for tooltip
  728.     if ($cfg['ShowTooltip'] && PMA_MYSQL_INT_VERSION >= 32303
  729.         && $num_tables) {
  730.         $tooltip = array();
  731.         $tooltip_name = array();
  732.         $result  = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE);
  733.         while ($tmp = PMA_DBI_fetch_assoc($result)) {
  734.             $tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
  735.             $tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] && $cfg['ShowTooltipAliasTB'] !== 'nested' ? $tmp['Name'] : $tmp['Comment']);
  736.  
  737.             $tooltip[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '')
  738.                                    . '(' . (isset($tmp['Rows']) ? $tmp['Rows'] : '0') . ' ' . $strRows . ')';
  739.         } // end while
  740.     } // end if
  741.  
  742.     // garvin: Get comments from PMA comments table
  743.     $db_tooltip = '';
  744.     if ($cfg['ShowTooltip'] && $cfgRelation['commwork']) {
  745.         $tmp_db_tooltip = PMA_getComments($db);
  746.         if (is_array($tmp_db_tooltip)) {
  747.             $db_tooltip = implode(' ', $tmp_db_tooltip);
  748.         }
  749.     }
  750.  
  751.  
  752.     // Displays the database name
  753.     if (!$cfg['LeftFrameLight']) {
  754.             $on_mouse = (($cfg['LeftPointerEnable'] == FALSE) ? '' : ' onmouseover="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftPointerColor'] . '\')}" onmouseout="if (isDOM || isIE4) {hilightBase(\'el2\', \'' . $cfg['LeftBgColor'] . '\')}"');
  755.  
  756.             echo "\n";
  757.             echo '    <div id="el2Parent" class="parent"' . $on_mouse . '>';
  758.  
  759.             if (!empty($num_tables)) {
  760.                 echo "\n";
  761.                 ?>
  762.         <div class="nowrap"><a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" onclick="if (capable) {expandBase('el2', true); return false} else {return true}">
  763.             <img name="imEx" id="el2Img" src="<?php echo $pmaThemeImage; ?>b_plus.png" border="0" width="9" height="9" alt="+" /></a>
  764.                 <?php
  765.             } else {
  766.                 echo "\n";
  767.                 ?>
  768.         <div class="nowrap"><img name="imEx" src="<?php echo $pmaThemeImage; ?>b_minus.png" border="0" width="9" height="9" alt="-" />
  769.                 <?php
  770.             }
  771.             echo "\n";
  772.             ?>
  773.         <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>" title="<?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db) : htmlspecialchars($db_tooltip)); ?>" onclick="if (capable) {expandBase('el2', false)}">
  774.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? '<i>' . htmlspecialchars($db_tooltip) . '</i>' : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a></div>
  775.     </div>
  776.  
  777.     <div id="el2Child" class="child" style="margin-bottom: 5px"<?php echo $on_mouse; ?>>
  778.     <?php
  779.     } else {
  780.         echo "\n";
  781.         ?>
  782.     <div id="el2Parent" class="parent nowrap">
  783.         <a class="item" href="<?php echo $cfg['DefaultTabDatabase']; ?>?<?php echo $common_url_query; ?>">
  784.             <span class="heada"><?php echo ($db_tooltip != '' && $cfg['ShowTooltipAliasDB'] ? htmlspecialchars($db_tooltip) : htmlspecialchars($db)); ?><bdo dir="<?php echo($text_dir); ?>">  </bdo></span><span class="headaCnt">(<?php echo $num_tables_disp; ?>)</span></a>
  785.     </div>
  786.     <div id="el2Child" class="child nowrap" style="margin-bottom: 5px">
  787.         <?php
  788.     }
  789.  
  790.     // Displays the list of tables from the current database
  791.     $tablestack = array();
  792.     $table_array = array();
  793.     while (list($table) = PMA_DBI_fetch_row($tables)) {
  794.         $table_item = (!empty($tooltip_name) && isset($tooltip_name[$table]) && !empty($tooltip_name[$table]) && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  795.                     ? htmlspecialchars($tooltip_name[$table])
  796.                     : htmlspecialchars($table));
  797.         $table_array[$table] = $table_item;
  798.     }
  799.  
  800.     if ($cfg['NaturalOrder']) {
  801.         natcasesort($table_array);
  802.     }
  803.  
  804.     $book_sql_cache = PMA_queryDBBookmarks($db, $cfg['Bookmark'], $table_array);
  805.     foreach ($table_array as $table => $table_sortkey) {
  806.         $alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
  807.                    ? htmlspecialchars($tooltip_name[$table])
  808.                    : '';
  809.         $url_title = (!empty($tooltip) && isset($tooltip[$table]))
  810.                    ? htmlspecialchars($tooltip[$table])
  811.                    : '';
  812.         $table_item = ($alias != '' && $cfg['ShowTooltipAliasTB'] && strtolower($cfg['ShowTooltipAliasTB']) !== 'nested'
  813.                     ? $alias
  814.                     : htmlspecialchars($table));
  815.         $tablename = ($alias != '' && $cfg['ShowTooltipAliasTB']
  816.                    ? $alias
  817.                    : htmlspecialchars($table));
  818.  
  819.         $book_sql_query = (isset($book_sql_cache[$table]) ? $book_sql_cache[$table] : FALSE);
  820.  
  821.         if ($cfg['LeftFrameLight']) {
  822.         echo "\n";
  823.         ?>
  824.             <a target="phpmain<?php echo $hash; ?>" href="sql.php?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>&sql_query=<?php echo (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))); ?>&pos=0&goto=<?php echo $cfg['DefaultTabTable']; ?>" title="<?php echo $strBrowse . ': ' . $url_title; ?>">
  825.                   <img src="<?php echo $pmaThemeImage . 'b_sbrowse.png'; ?>" width="10" height="10" border="0" alt="<?php echo $strBrowse . ': ' . $url_title; ?>" /></a><bdo dir="<?php echo $text_dir; ?>"> </bdo>
  826.               <a class="tblItem" id="tbl_<?php echo md5($table); ?>" title="<?php echo $url_title; ?>" target="phpmain<?php echo $hash; ?>" href="<?php echo $cfg['DefaultTabTable']; ?>?<?php echo $common_url_query; ?>&table=<?php echo urlencode($table); ?>">
  827.                   <?php echo $table_item; ?></a><br />
  828.         <?php
  829.         } else {
  830.             $list_item = '<a target="phpmain' . $hash . '" href="sql.php?' . $common_url_query . '&table=' . urlencode($table) . '&sql_query=' . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table))) . '&pos=0&goto=' . $cfg['DefaultTabTable'] . '" title="' . $strBrowse . ': ' . $url_title . '">';
  831.             $list_item .= '<img src="' . $pmaThemeImage . 'b_sbrowse.png" width="10" height="10" border="0" alt="' . $strBrowse . ': ' . $url_title . '" /></a>';
  832.             $list_item .= '<bdo dir="' . $text_dir . '"> </bdo>' . "\n";
  833.             $list_item .= '<a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table) . '">';
  834.             $list_item .= $table_item . '</a><br />';
  835.  
  836.             // garvin: Check whether to display nested sets
  837.             if (!empty($cfg['LeftFrameTableSeparator'])) {
  838.                 $_table = explode($cfg['LeftFrameTableSeparator'],  str_replace('\'', '\\\'', $tablename));
  839.                 if (is_array($_table)) {
  840.                     foreach ($_table AS $key => $val) {
  841.                         if ($val == '') {
  842.                             $_table[$key] = '__protected__';
  843.                         }
  844.                     }
  845.                     PMA_reduceNest($_table);
  846.  
  847.                     if (count($_table) == 1) {
  848.                         array_unshift($_table, '');
  849.                     }
  850.                     PMA_multimerge($tablestack, $_table);
  851.                 } else {
  852.                     $tablestack['']['pma_name'][] = $table_item;
  853.                     $tablestack['']['pma_list_item'][] = $list_item;
  854.                 }
  855.             } else {
  856.                 $tablestack['']['pma_name'][] = $table_item;
  857.                 $tablestack['']['pma_list_item'][] = $list_item;
  858.             }
  859.         }
  860.     } // end for $j (tables list)
  861.  
  862.     if (!$cfg['LeftFrameLight']) {
  863.         PMA_nestedSet('1', $tablestack);
  864.         ?>
  865.     </div>
  866.     <!-- Arrange collapsible/expandable db list at startup -->
  867.     <script type="text/javascript" language="javascript1.2">
  868.     <!--
  869.     if (isNS4) {
  870.       firstEl  = 'el1Parent';
  871.       firstInd = nsGetIndex(firstEl);
  872.       nsShowAll();
  873.       nsArrangeList();
  874.     }
  875.     var expandedDb = '<?php echo (empty($selected_db)) ? '' : 'el' . $selected_db . 'Child'; ?>';
  876.     //-->
  877.     </script>
  878.         <?php
  879.     } else {
  880.         echo '    </div>';
  881.     }
  882.  
  883.     echo "\n";
  884. } // end if ($num_dbs == 1)
  885.  
  886.  
  887. // Case where no database has to be displayed
  888. else {
  889.     echo "\n";
  890.     echo '<p>' . $strNoDatabases . '</p>';
  891. } // end if ($num_dbs == 0)
  892. echo "\n";
  893.  
  894. // 2004-08-05 added by Michael Keck
  895. //            reload queryframe if it exists and we delete a database
  896. //            or select a database from the db_list.
  897. $my_lightm_db = '';
  898. if (isset($lightm_db) && $lightm_db!='') {
  899.     $my_lightm_db = $lightm_db;
  900. }
  901.  
  902. if ($cfg['LeftFrameLight'] && $cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
  903.     if (!isset($table_array) || count($table_array)==0) {
  904.         $my_url_query = PMA_generate_common_url('', '', '&');
  905. ?>
  906. <script language="JavaScript" type="text/javascript">
  907. <!--
  908. function check_queryframe_reload() {
  909.     if (typeof(window.parent.frames['queryframe'])!='undefined' && typeof(window.parent.frames['queryframe'].document.forms['left'])!='undefined') {
  910.         if (window.parent.frames['queryframe'].document.forms['left'].elements['lightm_db'].value!='<?php echo $my_lightm_db; ?>') {
  911.             window.parent.frames['queryframe'].location.replace('<?php echo 'queryframe.php?' . $my_url_query . '&hash=' . $hash; ?>');
  912.         }
  913.     }
  914. }
  915. // This is a workaround for the problem in Safari 1.2.3 where the
  916. // top left frame does not load.
  917. // If we call this right away it usually prevents the top-left frame from
  918. // loading in Safari, so call it delayed. -Ryan Schmidt 2004-08-15
  919. setTimeout('check_queryframe_reload()', 1000);
  920.  
  921. //-->
  922. </script>
  923. <?php
  924.     }
  925. }
  926. ?>
  927. </div>
  928. </body>
  929. </html>
  930.  
  931. <?php
  932. /**
  933.  * Close MySql connections
  934.  */
  935. if (isset($dbh) && $dbh) {
  936.     @PMA_DBI_close($dbh);
  937. }
  938. if (isset($userlink) && $userlink) {
  939.     @PMA_DBI_close($userlink);
  940. }
  941.  
  942.  
  943. /**
  944.  * Sends bufferized data
  945.  */
  946. if (isset($cfg['OBGzip']) && $cfg['OBGzip']
  947.     && isset($ob_mode) && $ob_mode) {
  948.      PMA_outBufferPost($ob_mode);
  949. }
  950. ?>
  951.